home *** CD-ROM | disk | FTP | other *** search
- Path: sislnews.csc.ti.com!not-for-mail
- From: ramli@sislnews.csc.ti.com (C. S. Ramalingam)
- Newsgroups: comp.lang.c
- Subject: Re: Unable to check calloc`s
- Date: 7 Feb 1996 08:41:29 -0600
- Organization: Texas Instruments
- Message-ID: <4fadmp$t6g@osage.csc.ti.com>
- References: <4f2l8a$c98@gail.ripco.com>
- NNTP-Posting-Host: osage.csc.ti.com
-
- In article <4f2l8a$c98@gail.ripco.com>,
- Martin Ambuhl <mambuhl@ripco.com> wrote:
- s910500@acs.csc.cuhk.hk (CHAN CHUN CHUNG)
- in <4emept$ifv@hpg30a.csc.cuhk.hk> asks:
-
- [deleted]
-
- 4) calloc zeros out memory. This does not mean that pointers are set to
- NULL or that floating values are set to a value of floating point
- zero. It is also true that this is frequently wasted effort even
- for integral values. malloc() is usually what you want:
- #include <stdlib.h>
- {
- float **x;
- if (x = malloc(9*sizeof(float *))) == 0)
- exit(EXIT_FAILURE);
- }
-
- When would using calloc be more appropriate than using malloc ? Is it true
- that the only use for calloc is in initializing integral values to zero ?
- If so, why was a new function, which appears to have very limited used,
- introduced in the first place ?
-
-
- Thanks.
-
- ramli.
-
-
-
-